#!/bin/bash

database_name=$1

echo "Writing commit for database ${database_name}..."
echo "=========="

git add redist/${database_name}.tar.gz redist/${database_name}.tar.gz.md5 redist/${database_name}.mmdb.sha384
git status
git diff --staged

git config user.name "DBs Redist Updater"
git config user.email "bot@example.com"
git commit -m "chore(redist): update database ${database_name} - cron job GH-${GITHUB_RUN_NUMBER}" -m "https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" --no-verify
stat=$?
if [ $stat -ne 0 ]; then
	exit 1
fi

echo "=========="
echo "Commit written"
